home *** CD-ROM | disk | FTP | other *** search
- /*
- Copyright © 1991-1995 by TopSoft Inc. All rights reserved.
-
- You may distribute this file under the terms of the TopSoft
- Artistic License, accompanying this package.
-
- This file was developed by George (ty) Tempel in connection with TopSoft, Inc.
- See the Modification History for more details.
-
- Product
- About Box
-
- FILE
- ABMovieTopic.c
-
- NAME
- ABMovieTopic.c, part of the ABox project source code,
- responsible for handling the ABMovieTopic class stuff.
-
- DESCRIPTION
- This file contains defines for the about box modules.
-
- DEVELOPED BY
- George (ty) Tempel netromancr@aol.com
- All code in this file, and its associated header file was
- Created by George (ty) Tempel in connection with the TopSoft, Inc.
- "FilterTop" application development, except where noted.
-
- CARETAKER - George (ty) Tempel <netromancr@aol.com>
- Please consult this person for any changes or suggestions to this file.
-
- MODIFICATION HISTORY
-
- dd mmm yy - xxx - patchxx: description of patch
- 24 June 94 - ty - Initial Version Created
- 20-july-94 - ty - initial version released
- 28-july-94 - ty - 1.0.6 -- removed cursor flipping from Load
- 23-may-95 - ty - changes for compatibility with the CodeWarrior CW6
- release and the associated Universal Headers from Apple:
- most methods that returned references now have "Ref" at
- the end of their methods names to prevent possible collisions
- with datatypes and classes of the same name (older versions
- of the compiler didn't have a problem with this).
-
- */
-
- /*===========================================================================*/
-
- /*======= Segmentation directives ========*/
-
- #ifdef USE_MANUAL_SEGMENTATION
- #pragma segment ty
- #endif
-
- /*============ Header files ==============*/
-
- #include "ABMovieTopic.h"
- #include "ABoxDefs.h"
-
-
- /*=============== Globals ================*/
-
- /*================ CODE ==================*/
-
-
- /*=============================== ABMovieTopic::ABMovieTopic ================================*/
- ABMovieTopic::ABMovieTopic(const FSSpec& inTopicFSSpec)
- : ABTopic(inTopicFSSpec)
- {
- this->ResetSlideInfo();
-
- mBoxRect.left = mBoxRect.right = mBoxRect.top = mBoxRect.bottom = 0;
- this->TopicType() = ETopicType_MovieTopic;
- } // end ABMovieTopic
-
-
-
-
- /*=============================== ABMovieTopic::~ABMovieTopic ================================*/
- ABMovieTopic::~ABMovieTopic(void)
- {
- this->Close();
-
- } // end ~ABMovieTopic
-
-
-
- /*=============================== ABMovieTopic::GetProperty ================================*/
- OSErr ABMovieTopic::GetProperty(ABProperty prop,
- void *ptr,
- long *ptrSize)
- {
- OSErr error = noErr;
- long pSize;
-
- // begin here...
-
- if (!ptr)
- return kABPropertyNullStorage;
-
- switch (prop)
- {
- case kABTopicIsMovie:
- *((Boolean *)ptr) = true;
- pSize = kABTopicIsMovieSize;
- break;
- case kABTopicHasMovieController:
- *((Boolean *)ptr) = this->HasController();
- pSize = kABTopicIsMovieSize;
- break;
- case kABMovieFile:
- ::BlockMove ((Ptr)this->FSSpecPointerRef(), (Ptr)ptr, kABMovieFileSize);
- pSize = kABMovieFileSize;
- break;
- default:
- error = kABMovieTopicSuperProperties::GetProperty(prop, ptr, ptrSize);
- break;
- } // end switch block
-
- if (ptrSize && !error)
- *ptrSize = pSize;
- return error;
-
- } // end GetProperty
-
-
-
-
-
- /*=============================== ABMovie::SetProperty ================================*/
- OSErr ABMovieTopic::SetProperty(ABProperty prop,
- void *ptr,
- long ptrSize)
- {
- OSErr error = noErr;
- Boolean resolvedAliasChains = true,
- targetIsFolder = false,
- wasAliased = false;
-
-
- // begin here...
-
- if (!ptr)
- return kABPropertyNullStorage;
-
- switch (prop)
- {
- case kABTopicIsMovie:
- case kABTopicHasMovieController:
- error = kABPropertyReadOnly;
- break;
-
- case kABMovieFile:
- {
- FSSpec tFSS;
-
- ::BlockMove (ptr, (Ptr)&tFSS, kABMovieFileSize);
-
- error = ::ResolveAliasFile (&tFSS,
- resolvedAliasChains,
- &targetIsFolder,
- &wasAliased);
- if (!error && targetIsFolder)
- error = this->CheckAndCopyFSSpec (tFSS);
-
- }
- break;
- default:
- error = kABMovieTopicSuperProperties::SetProperty(prop, ptr, ptrSize);
- break;
- } // end switch block
-
- return error;
-
- } // end SetProperty
-
-
-
-
-
-
-
- /*=============================== ABMovieTopic::Resize ===============================*/
- //
- // this function will rearrange and resize the picture and the
- // text fields that appear on a slide.
- //
- // This method will cause the current slide for the
- // topic to resize by invoking that item's resize method.
- //
- // is called by:
- //
- OSErr ABMovieTopic::Resize (Rect const *field)
- {
- // begin here...
-
- if (!field)
- return paramErr;
- else
- this->BoxRectRef() = *field;
-
- return noErr;
- } // end of Resize
-
-
-
-
-
- /*=============================== ABMovieTopic::OpenTopic ================================*/
- OSErr ABMovieTopic::OpenTopic(void)
- {
- OSErr error = noErr;
- short movieResID = 0;
- short newMovieFlags = newMovieActive;
- Boolean dataRefWasChanged = false;
-
- // begin here...
-
- // now load the movie...
- //
- ABUCursor::WatchCursor();
- error = ::OpenMovieFile(this->FSSpecPointerRef(), &(this->FileRefNumRef()), fsRdPerm);
- if (error)
- {
- //ABoxDebug(kABErrQuickTimeOpenMovieFile, error);
- ABUCursor::ArrowCursor();
- return error;
- } // end if block
-
- //
- // NEW_movieFile
- //
- // the deal is that a file is selected but you do not know the moov id;
- // so we pass 0 for id to get the first moov resource available
- // (we do nothing with the returned ID, we could pass nil), nil for name pointer
- // and 0 for flags since I want a complete movie and don't want it to be active
-
- //ABoxDebugNew();
- error =:: NewMovieFromFile( &(this->MovieRef()), // the movie
- this->FileRefNumRef(), // file reference number
- &movieResID, // resource id
- nil, // resource name
- newMovieFlags, // newMovieFlags
- &dataRefWasChanged ); // dataRefWasChanged
-
- ABUCursor::ArrowCursor();
- if (error)
- {
- //ABoxDebug(kABErrQuickTimeNewMovieFromFile, error);
- return error;
- } // end if block
-
- ::CloseMovieFile(this->FileRefNumRef());
- this->ResetFileRefNum();
- return error;
- } // end OpenTopic
-
-
-
-
-
- /*=============================== ABMovieTopic::CloseTopic ================================*/
- OSErr ABMovieTopic::CloseTopic(void)
- {
- OSErr error = noErr;
-
- // begin here...
- ABUCursor::WatchCursor();
- error = this->Stop();
- ABUCursor::ArrowCursor();
- return error;
- } // end CloseTopic
-
-
-
-
-
-
-
- /*=============================== ABMovieTopic::DoLoad ===============================*/
- //
- OSErr ABMovieTopic::DoLoad (void)
- {
- OSErr error = noErr;
- Boolean fileOK = false;
-
- // begin here...
- //
- if (!ABUEnvQuickTime::IsPresent())
- {
- return paramErr;
- } else {
- error = this->Initialize();
- } // end if else block
-
- // begin here...
-
- error = ::OpenMovieFile(this->FSSpecPointerRef(), &(this->FileRefNumRef()), fsRdPerm);
- if (error)
- {
- return error;
- } // end if block
-
-
- ::CloseMovieFile(this->FileRefNumRef());
- this->ResetFileRefNum();
- //DisposeMovie(movie);
-
- return error;
-
- } // end of function DoLoad
-
-
-
- /*=============================== ABMovieTopic::DoCheckSlides ===============================*/
- //
- // This function checks a file for the presense of a topic/slide definition
- // resource and will an error type (OSErr)
- //
- // is called by:
- //
- short ABMovieTopic::DoCheckSlides (void)
- {
- OSErr error = noErr;
- const short hasNothing = 0;
- const short hasSomething = 1;
-
- // begin here...
- //
- if (!ABUEnvQuickTime::IsPresent())
- return hasNothing;
- else
- error = this->Initialize();
-
- error = this->OpenTopic();
- if (error)
- {
- this->ResetFileInfo();
- return hasNothing;
- } // end if (error) block
-
- error = this->CloseTopic();
- if (error)
- return hasNothing;
- else
- return hasSomething;
-
- } // end of function DoCheckSlides
-
-
-
-
-
- /*=============================== ABMovieTopic::Draw ================================*/
- OSErr ABMovieTopic::Draw(WindowPtr window)
- {
- OSErr error = noErr;
- Rect box;
-
- Rect movieRect;
- short movieResID = 0;
- short newMovieFlags = newMovieActive;
- Boolean dataRefWasChanged = false;
- short movieWidth,
- movieHeight;
-
- // begin here...
-
- if (this->DoesntHaveFSSpecPointer())
- return paramErr;
-
- if (!window)
- return paramErr;
-
- if (this->DoesntHaveMovie())
- {
- return paramErr;
- } // end if block
-
-
- // Draw a bezel around the field _including_ the scroll bar
- //
- box = this->BoxRectRef();
- this->EraseFrame (box);
- error = ABObject::Draw(window);
- if (error != noErr)
- return error;
-
- // set up the area for the movie...
- //
- ::GetMovieBox (this->MovieRef(), &movieRect);
- error = ::GetMoviesError();
- if (error)
- {
- error = this->Stop ();
- return (error);
- } // end if block
-
- error = this->ScaleRectToFit (movieRect, box, 1.0);
-
- movieWidth = movieRect.right - movieRect.left;
- movieHeight = movieRect.bottom - movieRect.top;
-
- movieRect.left = box.left + ((box.right - box.left) - movieWidth)/2;
- movieRect.right = movieRect.left + movieWidth;
- movieRect.top = box.top + ((box.bottom - box.top) - movieHeight)/2;
- movieRect.bottom = movieRect.top + movieHeight;
- ::SetMovieBox (this->MovieRef(), &movieRect);
-
- ::SetMovieGWorld(this->MovieRef(), (CGrafPtr)window, NULL); // point to the window...
- error = ::GetMoviesError();
- if (error)
- {
- error = this->Stop ();
- return (error);
- } // end if block
-
- // 1.0a3 ty ... additions for movie controller support
- //
- //ABoxDebugNew();
- if (this->DoesntHaveController())
- this->MovieControllerRef() = ::NewMovieController(this->MovieRef(),
- &movieRect,
- mcScaleMovieToFit | mcWithFrame);
- if (this->HasController())
- {
- ::MCGetControllerBoundsRect(this->MovieControllerRef(), &movieRect);
-
- // Peter Hoddie, Apple DTS, recommends in _develop_ #18
- // that this single line of code be used to activate
- // keyboard events for the controller.
- //MCDoAction (controller, mcActionSetKeysEnabled, (void *)true);
-
- // Peter also recommends turning on the movie controller
- // copy/cut/paste/clear functions via:
- //MCEnableEditing(controller, true);
- // and supplying event processing in the event loop. I'll
- // provide this in the Event method below
-
- } // end if block
-
- error = this->Begin();
-
- return error;
-
- } // end Draw
-
-
-
-
-
- /*=============================== ABMovieTopic::Update ================================*/
- OSErr ABMovieTopic::Update(WindowPtr /* window*/ )
- {
- // begin here...
- //
- Rect box = this->BoxRectRef();
-
- this->DrawFrame (box);
-
- return noErr;
-
- } // end Update
-
-
-
-
- /*=============================== ABMovieTopic::Event ================================*/
- Boolean ABMovieTopic::Event(EventRecord *eventRec)
- {
- OSErr error = noErr;
-
- Boolean test = false; // 1.0a4p3 ty...added variable
-
- // begin here...
-
- if (!(ABUEnvQuickTime::IsPresent() && this->HasMovie()))
- {
- return test; // 1.0a5 ty...changed to return test
- } // end if block
-
- // "play" the movie
- //
- if (this->HasController())
- {
- if (eventRec)
- { // 1.0a3 ty ... added check for event
- test = ::MCIsPlayerEvent(this->MovieControllerRef(), eventRec);
-
- } // end if block
- } else {
- // there is a movie, but the controller is defective, so give
- // some time to the movie.
- //
- test = ::IsMovieDone(this->MovieRef());
- if (!test)
- {
- ::MoviesTask(this->MovieRef(), kABserviceAllMovies);
- test = true;
- } // end if block
- } // end if else block
-
- return test;
- } // end Event
-
-
-
-
-
- /*=============================== ABMovieTopic::Stop ================================*/
- OSErr ABMovieTopic::Stop(void)
- {
- // begin here...
- //
- this->CleanUp();
- return noErr;
-
- } // end Stop
-
-
-
-
-
-
-
- // end of file
-
-